package cn.wellwan.observer;

/**
 * creator: maokai
 * on: 2018/3/27
 * description: 目前状况布告板
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionsDisplay (Subject weatherData) {
        this.weatherData = weatherData;
        //注册主题
        weatherData.registerObserver(this);
    }

    @Override
    public void display () {
        System.out.println("当前温度： " + temperature);
        System.out.println("当前湿度： " + humidity);
    }

    @Override
    public void update (float temp , float humidity , float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        this.display();
    }
}
